package cn.springbook.cim.config.upload;

import java.io.File;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfg implements WebMvcConfigurer {

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		
		
		// 文件磁盘图片url 映射
		// 配置server虚拟路径，handler为前台访问的目录，locations为files相对应的本地路径
		String uploadFolder = System.getProperty("user.dir") + File.separator + "upload"+ File.separator;
		System.out.println("=====" + uploadFolder);
		registry.addResourceHandler("/upload/**").addResourceLocations("file:" + uploadFolder);
	}

}
